# -*- encoding: utf-8 -*-
"""
@File    : 最长子回文.py
@Time    : 2020/11/1 19:05
@Author  : lluyao
@Email   : lluyao61@163.com
@Software: PyCharm
"""
def func(demo):
    demo_back = demo[::-1]
    # print(demo,demo_back)
    if demo == demo_back:
        return True
    else:
        return False

my_str = input('请输入字符串：')
result = dict()
max_lenght = 0
for i in range(len(my_str)):
    for j in range(i+1,len(my_str)+1):
        cut_str = my_str[i:j]
        print(cut_str)
        if func(cut_str):
            result[cut_str] = len(cut_str)
print(result)

for item in result.values():
    if item >= max_lenght:
        max_lenght = item
for key,value in result.items():
    if value == max_lenght:
        print(key)






